const { Menu, Tray } = require("electron")

const createTray = (app, win) => {
    const tray = new Tray('./src/assets/logo.png')
    tray.setToolTip('麦壳音乐')
    // 托盘点击事件, 设置托盘显示/隐藏的切换
    tray.on('click', () => win.isVisible() ? win.hide() : win.show())
    // 任务栏小图标的右键菜单栏设置
    const contextMenu = Menu.buildFromTemplate([
        { label: '艾怡良-Forever Young' },
        { label: '播放' },
        { label: '上一曲' },
        { label: '下一曲' },
        {
            label: '播放顺序',
            submenu: [
                { label: '随机播放' },
                { label: '列表循环' },
                { label: '单曲播放' },
                { label: '随机播放' }
            ]
        },
        {
            label: '最小化',
            submenu: [
                { label: '最小化' },
                { label: 'mini模式' },
                { label: '完成模式' }
            ]
        },
        { label: '打开桌面歌词' },
        { label: '锁定桌面歌词' },
        { label: '设置' },
        { label: '退出' },
        {
            label: '显示/隐藏', type: 'radio', checked: true, click: () => {
                win.isVisible() ? win.hide() : win.show()
            }
        },
        { label: '切换账号', }
    ])
    tray.setContextMenu(contextMenu)

}

module.exports = createTray
